package com.qdlc.p2p.biz.executer;

import java.util.HashMap;
import java.util.Map;

import com.qdlc.p2p.biz.util.NoticeTemplateSender;
import com.qdlc.p2p.dal.common.NoticeTypeHelper.NidType;
import com.qdlc.p2p.dal.dto.User;

public class NoticeExecutor implements BusinessExecutor{

	//通知nid
	private String noticeTypeNid;
	
	//指定特定的通知类型，也可以不指定，如果不指定，则发送存在的所有通知类型
	private NidType nidType;
	
	private Map<String, Object> sendData = new HashMap<String, Object>();
	
	public NoticeExecutor(String noticeTypeNid){
		this.noticeTypeNid = noticeTypeNid;
	}
	
	public NoticeExecutor(String noticeTypeNid, NidType nidType){
		this.noticeTypeNid = noticeTypeNid;
		this.nidType = nidType;
	}

	@Override
	public void execute(User user) {
		NoticeTemplateSender sender = NoticeTemplateSender.newInstance(user, noticeTypeNid, nidType);
		sender.addSendData(sendData);
		sender.send();
	}
	
	public void addSendData(Map<String, Object> sendData){
		this.sendData.putAll(sendData);
	}
	
	public void addSendData(String key, Object value){
		this.sendData.put(key, value);
	}
	
}
